import { routes } from '@/router/index'
import { filterRoutes } from '@/utils/routes'

const state = {
  routes: [],
}
const getters = {
  routes: (state) => state.routes,
}
const mutations = {
  setRoutes(state, routes) {
    state.routes = routes
  },
}
const actions = {
  setRoutes({ commit }) {
    const finallyRoutes = filterRoutes([...routes])
    commit('setRoutes', finallyRoutes)
  },
}

export default { state, getters, mutations, actions }
